<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="maximum-scale=3, minimum-scale=1, initial-scale=1, width=device-width, user-scalable=no">
		<title>向商家付款</title>
		<meta name="description" content="">
		<link rel="stylesheet" href="../../css/base.css" />
		<link rel="stylesheet" href="../../css/pay.css" />
		<script type="text/javascript" src="../../js/base.js" ></script>
		<script type="text/javascript" src="../../js/jquery-3.3.1.js" ></script>
		<script type="text/javascript" src="../../js/vue.js" ></script>
		<script type="text/javascript" src="../../js/keyboard.js" ></script>
		<script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
	</head>
	<body>
		<div class="vue">
			<div class="flex-left mch">
				<div class="mch-img">
					<img src="../../img/shanghu.png" class="w"/>
				</div>
				<div class="mch-name">
					<p class="name flex-left"><a class="type">门店</a>{{mchInfo.mchName}}</p>
					<!--<p class="mch-type flex-left"><a class="type">门店</a><a class="address">山东路旗舰店</a></p>-->
				</div>
			</div>
			<div class="flex-center money-input">
				<div class="flex-auto">
					<input placeholder="消费金额" disabled v-model="moneyValue"/>
					<img src="../../img/moeny.png" />
				</div>
			</div>
			<div class="keyboard">
				<!--<div class="qrcode flex-center">
					<div class="qrcode-img flex-center" v-if="qrcode">
						<div class="bj" @click="qrcode=false"></div>
						<img src="../../img/qrcode.jpg" class="w" />
					</div>
					<img src="../../img/qrcode.jpg" class="w" @click="qrcode=true"/>
					<p class="attention"><a>长按识别二维码，关注</a><a class="a" href="https://mp.weixin.qq.com/mp/profile_ext?action=home&__biz=MzI0MDExNzEzNQ==#wechat_redirect"> 滨分生活公众号 </a><a>送好礼</a></p>
				</div>-->
				<div class="number">
					<ul>
						<li>1</li>
						<li>2</li>
						<li>3</li>
						<li>4</li>
						<li>5</li>
						<li>6</li>
						<li>7</li>
						<li>8</li>
						<li>9</li>
						<li class="item">0</li>
						<li>.</li>
					</ul>
					<div>
						<div class="delete">
							<img src="../../img/delete.png" />
						</div>
						<p @click="confirmPay">确认<br/>支付</p>
					</div>
				</div>
			</div>
		</div>	
	</body>
	
	<script>
		var vue=new Vue({ 
			el:".vue",
			data:{
				qrcode:false,
				mchInfo:null,
				moneyValue:""
			},
			mounted:function(){
			 	this.mchInfo=JSON.parse(localStorage.mchInfo);
			},
			methods: {
				
				//确认支付
			    confirmPay: function () {
			    	let mchInfo=vue.mchInfo;
			    	let currentPrice=vue.moneyValue;
			    	if(!reg.test(currentPrice)){
			    		hint("金额格式错误");
			    		return 
			    	}
			    	
			    	let data={
			    		mchKey:localStorage.mchKey,
						currentPrice:currentPrice,
						browerType:localStorage.browerType,
						openMember:mchInfo.openMember,
						tradeTag:mchInfo.tradeTag,
						memTransType:localStorage.memTransType,
						memKey:mchInfo.memKey,
						orderNo:localStorage.orderNo
					};
			            	
			    	$.ajax({
						type:"post",
						url:url+"confirm_payment_amount",
						data:data,
						success:function(e){
							if(e.code=="0000"){
								localStorage.payInfo=JSON.stringify(e.result);
								if(e.result.toNext=="BALANCE_OK"){ //余额支付成功
						    		location.href="pay-result.html";
						    	} else if(e.result.toNext=="NONE"){ //不开启会员，直接支付订单
									let payInfo=JSON.parse(e.result.payParams.payInfo);
									wxPay(payInfo,function(){
										var url="/pages/index/navigationbar/navigationbar?iconPageThat=order&orderNo="+localStorage.orderNo;
										closePay(url,{
											iconPageThat:"order",
											orderNo:localStorage.orderNo
										});
									});
						    	}  else {
						    		location.href="noPay.html";
						    	}
							} else {
								hint(e.msg);
							}
						},
						error:function(e){
			    			hint(e.msg);
			    		}
					});
			    }
			}
		});
		
	</script> 
</html>